<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>

<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<body>
<script type="text/javascript">
	/*页面加载完成之后，执行function里面的代码*/
	$(function() {
		$('#sendAjax').click(function() {
			// 发送ajax请求
			$.get("../getPost?id=1", function(data) {
				console.log(data);
				var s = "id:" + data.id + " title:" + data.title + " content:" + data.content;
				$('#box').append(s);
			})
		});
	});
</script>


<button id="sendAjax">发送ajax请求</button>
<div id="box">
</div>
</body>
</html>